<template>
	<renderjs :option="option" :lazyLoad="lazyLoad" :canvasId="canvasId"  @changeOption="changeOption()" @getClickData="getClickData"></renderjs>
</template>

<script>
import renderjs from '@/mpvue-echarts/src/renderjs.vue';
export default {
	components: {
		renderjs
	},
	props: {
		option: {
			default: false
		},
		canvasId: {
			type: String,
			default: 'ec-canvas'
		},
		lazyLoad: {
			type: Boolean,
			default: false
		}
	},
	data() {
		return {
			option_demo: {
				title: {
					text: 'ECharts1'
				},
				xAxis: {
					data: ['衬衫1', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
				},
				yAxis: {},
				series: [
					{
						name: '销量',
						type: 'bar',
						data: [5, 20, 36, 10, 10, 20]
					}
				]
			}
		};
	},
	onLoad() {},
	methods: {
		changeOption() {
			const data = this.option.series[0].data;
			// 随机更新示例数据
			data.forEach((item, index) => {
				data.splice(index, 1, Math.random() * 40);
			});
		},
		getClickData(option) {
			console.log('点击的值', option);
		}
	}
};
</script>
